<!DOCTYPE html >
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>申请上门取件</title>
        <link href="/css/share.css" rel="stylesheet" type="text/css" />
        <link href="/css/express.css" rel="stylesheet" type="text/css" />
        <link href="/css/home/order.css" rel="stylesheet" type="text/css" />
        <link href="/css/pickupservice.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="/admins/js/jquery/jquery-1.7.2.min.js"></script>
        <script type="text/javascript" src="/js/boxy/js/jquery.boxy.js"></script>
    </head>

    <body>
        <!--top-->
        <div class="top">
            <div class="top_jz">
                <div class="Community">
                    <ul>
                        <li><a href="/">悠奇网首页</a></li>
                        <li><a href="http://help.uuch.com/" target="_blank">帮助中心</a></li>
                        <li><a target="_blank" href="http://crm2.qq.com/page/portalpage/wpa.php?uin=800035006&f=1&ty=1&aty=0&a=&from=6" onClick="_gaq.push(['_trackEvent', 'qq', 'open', 'top']);" title="悠奇,省钱的个人跨国物流服务">悠奇在线客服</a></li>
                        <li><a href="http://weibo.com/u/2830203612" target="_blank">新浪微博</a></li>
                    </ul>
                </div>  
                <div class="user">
                    <ul>
                        <li class="user_login">
                            <?php if($this->isLogin){ ?>
                            <p><?php echo $this->user->nikename ?>! 欢迎来到悠奇！<a href="/user/logout">[退出]</a></p>
                            <?php }else{?>
                            <p>亲！欢迎来到悠奇！<a href="/user/login">[登录]</a><a href="/user/join">[注册]</a></p>
                            <?php }?>
                        </li>
                        <li class="user_cart"><a href="/purchase/cart"><span>购物车</span></a></li>
                        <li class="user_cart"><a href="/member/mail"><span>短消息</span><?php echo '<em class="'.($this->mainCount==0?'kong':'').'">'.$this->mainCount.'</em>'; ?></a></li>
                        <li class="user_cart"><a href="/tool/express"><span>运费试算</span></a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="headerzy">
            <div class="headerzy_Center">
                <div class="logozy">
                    <div class="headerzy_logo">
                        <a href="/"><img src="/images/share/logo2.png" alt="悠奇网" /></a>
                    </div>
                    <div class="headerzy_lm">
                        <h1>申请上门取件</h1>
                        <div class="headerzy_dh">
                            <a href="javascript:void(0)" class="headerzy_s"><i></i>导航</a>
                            <div class="headerzy_xl" style="display:none;">
                                <a href="/member/home">我的账户</a>
                                <a href="/store/home">个人云仓库</a>
                                <a href="/purchase/index">代购服务</a>
                                <a href="/store/express">国际速递</a>
                                <a href="/tool/pay">跨国支付服务</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="headerzy_you">
                    <ul>
                        <li>国内上门取货</li>
                        <li>国外送货到家</li>
                    </ul>
                    <p>足不出户也能发国际快递，省时省力又省钱！</p>
                </div>
            </div>
        </div>

<div class="centershare">
    <div class="yundan">
        <form method="post" action="/store/vswaysubmit" id="f_waybill">
        <div class="OrderData">
            <div class="ODleft">
                运单信息
            </div>
            <div class="ODright">
                <div class="infobox">
                    <div class="Oinfo">
                        <h1>您本次共提交<span>1</span>个上门取件物品，物品重量为<span><?= $this->weight ?></span>g</h1>
                    </div>
                    <div class="baoguo">
                        <div class="bg">
                            <h2>预估包裹重量：<em><?= $this->weight + $this->bagWeight ?></em>g</h2><span>(打包后的重量,含包装箱<?= $this->bagWeight  ?>g)</span><a href="http://help.uuch.com/?p=216">了解包裹重量？</a>
                        </div>
                        <? if($this->volumeWeight >$this->weight + $this->bagWeight){ ?>
                        <div class="tj">
                            <h2>预估体积重量：<em><?= $this->volumeWeight ?></em>g</h2><span>(部分快递公司规定，结算重量时，取体积重量与实际重量两者中较大者进行结算。)</span>
                        </div>
                        <? } ?>
                    </div>
                    <div class="jsts" style="height: 40px;">
                        <p><i></i>运单结算时根据预估重量收取运费，最终以实际重量为准，多收费用部分退还您的悠奇帐户！</p>
                        <?= $this->formHidden('weight',$this->weight) ?><?= $this->formHidden('bagWeight',$this->bagWeight) ?>
                        <?= $this->formHidden('SumWeight',$this->SumWeight) ?><?= $this->formHidden('volumeWeight',$this->volumeWeight) ?><?= $this->formHidden('waresDescribe',$this->waresDescribe) ?>
                        <?= $this->formHidden('adid',$this->cnAddress->id) ?><?= $this->formHidden('inlandShipType',$this->inlandShipType) ?><?= $this->formHidden('itemType',$this->itemType) ?>
                        <?= $this->formHidden('waresName',$this->waresName) ?><?= $this->formHidden('inlandMoney',$this->inlandMoney) ?><?= $this->formHidden('packageSize',$this->packageSize) ?>
                        <p style="color:#c00;">寄送点：中国<?php echo $this->cnAddress->CityByCityId->name.$this->cnAddress->TownBy->name.$this->cnAddress->street;?></p>
                    </div>
                    <div class="QDtable">
                        <table>
                            <tr>
                                <th class="q2" style="width: 300px;">名称</th>
                                <th class="q3" style="width: 80px;">物流属性</th>
                                <th class="q3" style="width: 50px;">物品净重</th>
                                <th class="q4" style="width: 80px;">体积重量</th>
                                <th class="q4" style="width: 80px;">国内运送</th>
                                <th class="q4" style="width: 50px;">国内运费</th>
                            </tr>
                            <tr >
                                <td><?= $this->waresName."<br>".(mb_strlen($this->waresDescribe)>20?mb_substr($this->waresDescribe, 0, 20, "utf-8")."...":$this->waresDescribe) ?></td>
                                <td style="text-align: center;">
                                    <?php $nameAll = "";
                                        if($this->itemType){
                                            foreach($this->typeName as $key=>$name){
                                                if($key != 0 && ($this->itemType & $key) == $key){
                                                   $nameAll = $nameAll. $name[0].'/';                
                                                }
                                            }
                                         }else{
                                             $nameAll = "正常";
                                         }
                                         echo $nameAll;
                                    ?>
                                </td>
                                <td style="text-align: center;"><?= $this->weight ?>g</td>
                                <td style="text-align: center;"><?= $this->volumeWeight?$this->volumeWeight."g<br>(".$this->packageSize."/5000)kg":'(无)'  ?></td>
                                <td style="text-align: center;"><?= $this->inlandShipItem->name  ?></td>
                                <td style="text-align: center;"><?= $this->inlandMoney?number_format($this->inlandMoney,2):'(无)'  ?></td></tr>
                         </table>
                    </div>
                    <div class="Ochange"><a href="javascript:history.go(-1);"><<修改取件商品信息</a></div>
                </div>
            </div>
        </div>
        
        <div class="OrderData">
            <div class="ODleft">
                收货信息
                <?= $this->formHidden('addressId',$this->default->Id) ?>
                <?= $this->formHidden('cityId',$this->default->State) ?>
            </div>
            <div class="ODright">
                <div class="dizhi"<?= $this->hasAddress?'':' style="display:none"' ?>>
                    <table>
                        <tr>
                            <td>收 货 人：</td>
                            <td id="c_linkMan"><?= $this->default->LinkMan ?></td>
                        </tr>
                        <tr>
                            <td>收货国家：</td>
                            <td id="c_stateText"><?= $this->default->StateText ?></td>
                        </tr>
                        <tr>
                            <td>收货地址：</td>
                            <td id="c_street"><?= $this->default->Street ?></td>
                        </tr>
                        <tr>
                            <td>邮　　编：</td>
                            <td id="c_postCode"><?= $this->default->Postcode ?></td>
                        </tr>
                        <tr>
                            <td>电　　话：</td>
                            <td id="c_mobile"><?= $this->default->Mobile ?></td>
                        </tr>
                    </table>
                </div>
                <div class="Ochange" <?= $this->hasAddress?'':' style="display:none"' ?>>
                    <a id="aOchange" href="javascript:void(0)">更改收货地址</a>
                </div>
                
                <div id="dizhichange" class="dizhichange"<?= $this->hasAddress?' style="display:none"':'' ?>>
                    <table class="changeHX">
                        <?php foreach ($this->address as $item) { ?>
                        <tr<?= $item->Id == $this->default->Id?' class="changeON"':'' ?>>
                            <td class="dzcz">
                                <input class="useaddr" name="useaddr"<?= $item->Id == $this->default->Id?' checked="true"':'' ?> type="radio" value="<?= $item->Id ?>" />
                                <input class="useState" type="hidden" value="<?= $item->State ?>"/>
                            </td>
                            <td>
                                <p><span class="s_street"><?= $item->Street ?></span>，邮编：<span class="s_postCode"><?= $item->Postcode ?></span></p>
                                <p>收货人：<span class="s_linkMan"><?= $item->LinkMan ?></span>，电话：<span class="s_mobile"><?= $item->mobile ?></span> 国家：<span class="s_stateText"><?= $item->StateText ?></span></p>
                            </td>
                        </tr>                            
                        <?php }?>
                        <tr>
                            <td class="dzcz"><input id="usenew" class="useaddr" name="useaddr"<?= $this->hasAddress?'':' checked="true"' ?> type="radio" value="<?= $item->Id ?>" /></td>
                            <td>
                                <p>使用新地址</p>
                            </td>
                        </tr>
                    </table>
                    <div class="newdz"<?= $this->hasAddress?' style="display:none"':'' ?>>
                        <table>
                                <tr>
                                    <td class="new_z"><span>*</span>所在国家：</td>
                                    <td>
                                        <div class="guojiabox">
                                            <div class="guyojiatext"><input type="text" readonly="readonly" id="stateText" name="stateText" /><a href="javascript:void(0)"></a></div>
                                            <input type="hidden" class="state" id="state" name="state" />
                                            <div class="guojiaceng" style="display:none;">
                                                <div class="remen">
                                                    <h2>热门国家和地区</h2>
                                                    <ul class="countrylist">
                                                        <li><a href="#" id="c_us" cid="1">美国</a></li>
                                                        <li><a href="#" cid="2">加拿大</a></li>
                                                        <li><a href="#" cid="3">澳大利亚</a></li>
                                                        <li><a href="#" cid="47">日本</a></li>
                                                        <li><a href="#" cid="39">台湾</a></li>
                                                        <li><a href="#" cid="4">新西兰</a></li>
                                                        <li><a href="#" cid="5">英国</a></li>
                                                        <li><a href="#" cid="42">马来西亚</a></li>
                                                    </ul>
                                                </div>
                                                <div class="allcountry">
                                                    <h2>全部国家和地区</h2>
                                                    <ul class="countryzm">
                                                        <?php
                                                        foreach ($this->words as $char){
                                                        ?>
                                                        <li <?= $char=='A'?'class="zmon"':'' ?>><a href="#"><?= $char ?></a></li>
                                                        <?php }
                                                        ?>

                                                    </ul>
                                                    <div id="countryTab">
                                                    <?php
                                                    foreach ($this->words as $char){
                                                    ?>
                                                <ul class="countrylist"  <?= $char=='A'?'':'style="display:none"' ?>>
                                                    <?php
                                                    $citys= Application_Model_city::GetBySortCode($char);
                                                    foreach ($citys as $city){
                                                    ?>
                                                        <li><a href="#" cid="<?= $city->Id ?>"><?= $city->Name ?></a></li>
                                                        <?php } ?>
                                                    </ul>
                                                    <?php
                                                        }
                                                    ?>
                                                    </div>
                                                </div>
                                                
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="new_z"><span>*</span>详细地址：</td>
                                    <td><input class="text400 " name="street" maxlength="500" id="street" type="text" /><br />(英语地址,请包含州(省),城市)</td>
                                </tr>
                                <tr>
                                    <td class="new_z"><span>*</span>邮政编码：</td>
                                    <td><input class="text" name="postCode" maxlength="20" id="postCode" type="text" /></td>
                                </tr>
                                <tr>
                                    <td class="new_z"><span>*</span>收货人：</td>
                                    <td><input class="text " name="linkMan" maxlength="50" id="linkMan" type="text" /></td>
                                </tr>
                                <tr>
                                    <td class="new_z"><span>*</span>联系电话：</td>
                                    <td><input class="text " name="mobile" id="mobile" maxlength="20" type="text " />
                                    </td>
                                </tr>
                            </table>
                    </div>
                    <div class="changeok">
                          <a class="baocun" href="#"><span>确定</span></a><a class="quxiao" href="#"><span>取消</span></a>
                    </div>
                </div>
            </div>
        </div>
        <div class="OrderData">
            <div class="ODleft">
                配送方式
            </div>
            <div class="ODright">
                <div class="kuaidi">
                    <?php if($this->hasAddress){ ?>
                    <table>
                        <tr>
                            <th class="kd1">快递方式选择</th>
                            <th class="kd2">受理情况</th>
                            <th class="kd3">是否按<br />体积重量</th>
                            <th class="kd4">结算重量</th>
                            <th class="kd5">预计天数</th>
                            <th class="kd6">金额(￥)</th>
                        </tr>
                        <?php 
                        $showItem= function($item,$view,$nameAll){
                            $accept =true;
                            $message ='';
//                            foreach ($view->items as $si){
                                $itemAccept =$item->isAccept($view->itemType);
                                if((!$itemAccept) && !strpos($message,$nameAll)){
                                    $message .= ' 不接受'.$nameAll;
                                }
                                $accept = $accept && $itemAccept;
//                            }
                            //如果大于2000，Air不接受
                            if($item->Express->subsequentWeight == 100 && $view->SumWeight > 2000){
                                $accept = FALSE;
                                $message .= ' 不接受大于2KG的包裹';
                            }
                            if(strpos('-'.$item->Express->Name,'EMS') && $view->SumWeight > 30000){
                                $accept = FALSE;
                                $message .= ' 不接受大于30KG的包裹';
                            }
                            if($item->SortKey !== false){
                                //如果后台没有设置对应价格不让选择
                        ?>
                        <tr>
                            <td class="kd1">
                                <label>
                                    <input data="<?= $item->Express->ReportFee ?>" type="radio" <?= $accept?'':' disabled="disabled"' ?> class="shiptyperadio" value="<?= $item->ExpressId?>" name="shipType" />
                                    <span><?= $item->getExpress()->Name ?></span></label>
                            </td>
                            <td class="kd2"><?= $message?"<span>$message</span>":'可受理' ?></td>
                            <td class="kd3"><?= $item->Express->IsVolume?'是':'<p style="color:green">否</p>' ?></td>
                            <td class="kd4"><?= $item->Express->IsVolume&& $view->volumeWeight> $view->SumWeight? $view->volumeWeight : $view->SumWeight ?>g</td>
                            <td class="kd5"><?=  $item->times?><input type="hidden" id="isRemoteFee" name="isRemoteFee" value="<?php echo $item->Express->IsRemoteFee;?>" />工作日</td>
                            <td class="kd6"><?= number_format($item->SortKey,2) ?></td>
                        </tr>
                        <?php } ?>
                        <?php }; ?>
                        <?php
                             foreach ($this->prices as $item){
                                 $weight=0;
                                 if($item->Express->IsVolume && $this->volumeWeight>$this->SumWeight)
                                     $weight = $this->volumeWeight;
                                 else
                                     $weight = $this->SumWeight;
                                 $item->SortKey = $item->getMoneyByweight($weight);
                             }
                             $prices = Uuch_Util::quickSort($this->prices, 'SortKey');
                             $air = NULL;
                             foreach($prices as $item){   
                                 if($item->ExpressId == Application_Model_Express::Expredd_ReceiveUser){
                                    continue;
                                 }
                                 //被禁止
                                 if($item->Express->isDisable == 1){ 
                                     continue;
                                 }
                                 //东西马
                                 if($this->isEast){
                                     if($item->ExpressId == Application_Model_Express::Express_WesternA || $item->ExpressId == Application_Model_Express::Express_WesternB){
                                         continue;
                                     }
                                 } else {
                                     if($item->ExpressId == Application_Model_Express::Express_EastA || $item->ExpressId == Application_Model_Express::Express_EastB){
                                         continue;
                                     }
                                 }
                                //跳过AIR，在最后面补上
                                 if($item->Express->MaxWeight == 2000){
                                     continue;;
                                 }
                                 $showItem($item,$this,$nameAll);                                                       
                            }
                            foreach($prices as $item){
                                //因为香港小包最近延误太久，先关掉
                                 if($item->ExpressId ==  Application_Model_Express::Expredd_ReceiveUser){
                                     continue;
                                 }
                                 //被禁止
                                 if($item->Express->isDisable == 1){ 
                                     continue;
                                 }
                                if($item->Express->MaxWeight == 2000){
                                    $showItem($item,$this,$nameAll);       
                                }
                            } ?>
                    </table>
                    <?php } ?>
                    <h4><i></i>温馨提示：选择中邮小包运送周期长、丢包率高、物流跟踪不畅，如急用或贵重物品请慎重选择！</h4>
                </div>
            </div>
        </div>
        
        <div class="OrderData">
            <div class="ODleft">
                增值服务
            </div>
            <div class="ODright">
				<div class="tese">
                	<ul>
                    	<li>
                        	<label><input id="isNoPackage" name="isNoSkin" type="checkbox" value="1" />去掉物品非必要包装<span>[免费]</span></label>
                            <p>此项操作可以缩减包裹的重量和体积，节省运费，非必要包装如：鞋盒、填充物等！</p>
                        </li>
                    	<li>
                        	<label><input id="isNoLogo" name="isNoLogo" type="checkbox" value="1" />取出商品吊牌/发票<span>[服务费:+20元]</span></label>
                            <p>此项可避免海关根据标价收取关税，还能减小被认定为商业包裹的几率。</p>
                        </li>
                    	<li>
                        	<label><input id="isKong" name="isCompress" type="checkbox" value="1" />真空压缩服务，减少体积重量<span>[服务费:+20元]</span></label>
                            <p>使用压缩服务后节省金额如小于10元此项不收费。</p>
                        </li>
                    	<li>
                        	<label><input id="isWooden" name="isWooden" id="isWooden" type="checkbox" value="1" />护角加固服务，减少易碎品破损率<span>[费用:+50元]</span></label>
                            <p>费用包含材料费、操作费！</p>
                        </li>
                    </ul>
                    
                </div>
            </div>
        </div>
        
        <div class="OrderData">
            <div class="ODleft">
                申报信息
            </div>
            <div class="ODright">
            	<div class="sbao">
                    <table>
                        <tr>
                            <td class="fyz">包裹申报价值：</td>
                            <td>
                            	<div class="sbinput">
                                    <input type="text" name="reportValue" class="number" id="reprotValue" />
                                    <i>输入美元价值</i>
                                    <span>USD($)</span>
                                </div>
                                <div class="sbjz">
                                	<p>海关对包裹收取关税的依据，申报过低可能罚款，申报过高则可能会缴纳更多关税！<a target="_blank" href="http://help.uuch.com/?p=494">申报技巧</a></p>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="fyz">购买保险：</td>
                            <td>
                            	<div class="baoxian">
                                    <ul>
                                        <li><label><input name="isPremium" class="isPremium" id="isPremium1" type="radio" value="1" />是</label></li>
                                        <li><label><input name="isPremium" class="isPremium" checked="checked" id="isPremium2" type="radio" value="0" />否</label></li>
                                        <li><a href="http://help.uuch.com/?p=492" target="_blank">关于保险？</a></li>
                                    </ul>
                                </div>
                                <div class="baoxiangm" style="display:none">
                                	<ul>
                                    	<li>
                                            <label>保险种类：</label>
                                            <span>收取投保价值的3%作为保费</span>
                                        </li>
                                        <li>
                                        	<label>投保价值：</label>
                                            <div class="tbje">
                                                <input type="text" name="PremiumValue" class="number" id="PremiumValue" /><i>人民币</i><span>元(￥)</span>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        
        <div class="OrderData">
            <div class="ODleft">
                备注
            </div>
            <div class="ODright">
				<div class="tese">
                    <p style="margin-bottom:10px;">清关税号: <?= $this->formText('dutyNo') ?><span style="color:#ccc">(可不填,如填写,有利于帮您快速清关,德国,巴西等部分国家不填将不能正常发货)</span></p>
                	<?= $this->formTextarea('remark',null,array('cols'=>80,'rows'=>'5')) ?>
                    <?= $this->formHidden('isEuro',$this->isEuro) ?>
                    <p style="color:gray">您可在备注里面写上您的一些特殊要求</p>
                </div>
            </div>
        </div>
            
        <div class="OrderData">
            <div class="ODleft">
                收费详情
            </div>
            <div class="ODright">
                <div class="feiyong">
                    <table>
                        <tr>
                            <td class="fyz">国 际 运费：</td>
                            <td><label id="shipFee"><?= $this->hasAddress?$prices[0]->SortKey:'0'?></label>元</td>
                        </tr>
                        <tr>
                            <td class="fyz">国 内 运费：</td>
                            <td><label id="cnShipFeeLabel"><?= number_format($this->inlandMoney,2) ?><?= $this->formHidden('cnShipFee',$this->inlandMoney) ?></label>元</td>
                        </tr>
                        <tr id="removalRow" style="display:none">
                            <td class="fyz">吊牌取出费：</td>
                            <td><label id="removalsFee">20.00</label>元</td>
                        </tr>
                        <tr id="compressRow" style="display:none">
                            <td class="fyz">真空压缩袋：</td>
                            <td><label id="compressFee">20.00</label>元</td>
                        </tr>
                        <tr id="woodenRow" style="display:none">
                            <td class="fyz">木架加固费：</td>
                            <td><label id="woodenFee">50.00</label>元</td>
                        </tr>
                        <tr id="remoteFeeRow" style="display:none">
                            <td class="fyz">偏　远　费：<?= $this->formHidden('foRemoteFee',Application_Model_RemoteFee::remoteFee) ?></td>
                            <td><label id="remoteFee">80.00<?= $this->formHidden('isZipRemoteFee',$this->isZipRemoteFee) ?></label>元</td>
                        </tr>
                        <tr id="premiumRow" style="display:none">
                            <td class="fyz">保　　　费：</td>
                            <td><label id="premiumFee">0.00</label>元</td>
                        </tr>
                        <tr id="coupon_row" style="display:none">
                            <td class="fyz">优　惠　券：</td>
                            <td><em>-0.00元</em><?= $this->formHidden('cnShipFee',$this->cnShipFee) ?></td>
                        </tr>
                        
                    </table>
                </div>
            </div>
        </div>
        
        <div class="accounts_num">
                <table>
                    <tr>
                        <td class="preferential">
                                                   
                        </td>
                        <td class="total"><span>应付总额：</span><em id="amount">￥0.00</em><span>元</span></td>
                    </tr>
                </table>
        </div>
        <div class="Order_ok">
            <dl>
                <dt>
                    <div class="Qbz" style="display:none;">您选择了去掉物品非必要包装，此项节省的钱将返回您的RMB帐户！</div>
                </dt>
                <dd><input name="btn_submit" value="" id="btn_submit" type="button" onmouseover="this.className='Order_After'" onmouseout="this.className=''" /></dd>
            </dl>
            
        </div>
        </form>
        
    </div>
</div>
<script type="text/javascript">
$(function(){  
    $('#btn_submit').click(function(){
        if($('#addid').val()=='' || $('#dizhichange').is(':visible')){
            alert('请保存您的收货地址后再提交国际运单。');
            return false;
        }
        if($('.shiptyperadio:checked').length == 0){
            alert('请选择可以的配送方式。');
            return false;
        }
        $('#f_waybill').submit();
        $('#btn_submit').unbind('click');
    });
    
    $('#aOchange').click(function(){
         $('#dizhichange').show();
        $('.dizhi,.Ochange').hide();
        return false;
    });
    //---国家选择器---
    $('.guojiabox').hover(function(){
        //$('.guojiaceng').show();
    },function(){
        $('.guojiaceng').hide();
    });
    $('.guyojiatext').click(function(){
        $('.guojiaceng').show();
    });
    $('.countrylist a').bind('click',function(){
        var city =$(this).text();
        $('#stateText').val(city);
        
        $('.guojiabox #state').val($(this).attr('cid'));
        $('.guojiaceng').hide();
        return false;
    });
    $('.countryzm a').each(function(index,item){
        $(item).click(function(){
            $('.countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#countryTab ul').hide();
            $('#countryTab ul').eq(index).show();
            return false;
        });
    });
    
    $('.useaddr').live('change',function(){
        if($('#usenew').is(':checked')){
            $('.newdz').show();
        }else{
            $('.newdz').hide();
        }
        $('.changeON').removeClass('changeON');
        $(this).parents('tr').addClass('changeON');
    });
    function validAddress(){
        if($('#state').val()==''){
            alert('请选择国家');
            $('#state').focus();
            return false;
        }
        if($('#street').val()==''){
            alert('请输入详细地址');
            $('#street').focus();
            return false;
        }
        if($('#postCode').val()==''){
            alert('请输入邮编');
            $('#postCode').focus();
            return false;
        }
        if($('#linkMan').val()==''){
            alert('请输入收货人');
            $('#linkMan').focus();
            return false;
        }
        if($('#mobile').val()==''){
            alert('请输入电话');
            $('#mobile').focus();
            return false;
        }
        return true;
    }
    $('.baocun').click(function(){
        var posts= {};
        $('.kuaidi table').css('visibility','hidden');
        if($('#usenew').is(':checked')){
            if(!validAddress()){
                return false;
            }
            
            var html = '<tr class="changeON">'
                         +   '<td class="dzcz">'
                         +  '<input class="useaddr" name="useaddr" checked="true" type="radio" value="" />'
                         +       '<input class="useState" type="hidden" value=""/>'
                         +   '</td>'
                         +  '<td>'
                         +       '<p><span class="s_street"></span>，邮编：<span class="s_postCode"></span></p>'
                         +       '<p>收货人：<span class="s_linkMan"></span>，电话：<span class="s_mobile"></span> 国家：<span class="s_stateText"></span></p>'
                         +   '</td>'
                         +'</tr>';
            $('.changeHX tr').eq(0).before(html);
            var newrow = $('.changeHX tr').eq(0);
            $('.newdz :input').each(function(index,item){
                posts[$(item).attr('name')]=$(item).val();
            });
            for(var item in posts){
                $('#c_'+item).text(posts[item]);
            }
            for(var item in posts){
                newrow.find('.s_'+item).text(posts[item]);
            }
            posts["weight"] = $("#SumWeight").val();
            posts["volumeWeight"] = $("#volumeWeight").val();
            posts["itemType"] = $("#itemType").val();
            $.post('/store/newforeignaddress', posts, function(data){
                $('.kuaidi').html(data);
                $('#isEuro').val($('#isEuro2').val());
                if($('#isEuro').val()){
                    $('#eoridiv').show();
                }else{
                    $('#eoridiv').hide();
                }
                $("#isZipRemoteFee").val($('#isZipRemoteFee2').val());
                newrow.find('.useaddr').val($('.kuaidi #newAddressId').val());
                $('.shiptyperadio:enabled').first().click();
                $('#addressId').val($('.kuaidi #newAddressId').val()); 
            }, 'html');            
            $('.newdz').hide();
        }else{
            $('.useaddr:checked').parents('tr').find('span').each(function(index,item){
                posts[$(item).attr('class').substr(2)]=$(item).text();
            });
            $('.kuaidi').append('正在获取运费,请稍等...');
            for(var item in posts){
                $('#c_'+item).text(posts[item]);
            }
            $.post('/store/cultfee', {'address':$('.useaddr:checked').val(),"weight":$("#SumWeight").val(),"volumeWeight":$("#volumeWeight").val(),"itemType":$("#itemType").val()}, function(html){
                $('.kuaidi').html(html);
                $('#isEuro').val($('#isEuro2').val());
                if($('#isEuro').val()){
                    $('#eoridiv').show();
                }else{
                    $('#eoridiv').hide();
                }
                $("#isZipRemoteFee").val($('#isZipRemoteFee2').val());
                $('.shiptyperadio:enabled').first().click();
                $('#addressId').val($('.useaddr:checked').val());                
            }, 'html');        
        }                
        $('#dizhichange').hide();
        $('.dizhi,.Ochange').show();  
        return false;
    });
    
    $('.shiptyperadio').live('change',function(){
        var shipfee = $(this).parents('tr').find('.kd6').text();
        $('#shipFee').text(shipfee);        
        var reportFee = parseInt($(this).attr('data'));
        if(isNaN(reportFee))
            reportFee =0;
        $('#show_reportFee').text(changeTwoDecimal_f(reportFee) );
        cultAmount();
    });
    
    function changeTwoDecimal_f(x)
    {   
        var f_x = parseFloat(x);
        if (isNaN(f_x))
        {
            return x;
        }
        f_x = Math.round(f_x*100)/100;
        var s_x = f_x.toString();
        var pos_decimal = s_x.indexOf('.');
        if (pos_decimal < 0)
        {
            pos_decimal = s_x.length;
            s_x += '.';
        }
        while (s_x.length <= pos_decimal + 2)
        {
            s_x += '0';
        }
        return s_x;
    }
    
    function cultAmount(){
        var shipfee = $('.shiptyperadio:checked').parents('tr').find('.kd6').text().replace(',','').replace(',','');
        var isRemoteFee = $('.shiptyperadio:checked').parents('tr').find('#isRemoteFee').val();
        var isZipRemoteFee = $("#isZipRemoteFee").val();
        var reportFee = 0;
//        var data = $('.couponno:checked').attr('data');
//        if(data != 0){
//            $.post('/member/validatecoupon', {'couponno':$('.couponno:checked').val(),'money':$('#shipfee').text()}, function(result){
//                if(!result.result){
//                    alert(result.message);
//                }else{
//                    $('#coupon_row em').text('-'+changeTwoDecimal_f(result.discount));
//                    var compressFee = $('#isKong').is(':checked')?10:0;
//                    var woodenFee = $('#isWooden').is(':checked')?200:0;
//                    var premiumFee = 0;
//                    if($('#isPremium1').is(':checked')){
//                        premiumFee = parseFloat($('#premiumFee').text());
//                    }
//                    var money = parseFloat(shipfee) - parseFloat(result.discount) + reportFee + parseFloat($('#cnShipFee').val()) + compressFee + woodenFee + premiumFee ;
//                    if(money<0)
//                        money=0;
//                    $('#amount').text('￥'+ changeTwoDecimal_f(money));
//                    $('#cou_count').text('1');
//                    $('#cou_money').text(changeTwoDecimal_f(result.discount));
//                }
//            }, 'json').fail(function(){alert('验证出错了,请联系客服');});
//        }else{
            $('#coupon_row em').text('-'+changeTwoDecimal_f(0));
            var compressFee = $('#isKong').is(':checked')?20:0;
            var woodenFee = $('#isWooden').is(':checked')?50:0;
            var removalFee = $('#isNoLogo').is(':checked')?20:0;
            var foRemoteFee = 0;
            if(isRemoteFee == 1 && isZipRemoteFee) {
                foRemoteFee = $("#foRemoteFee").val(); //偏远费
                $("#remoteFeeRow").show();
            } else {
                $("#remoteFeeRow").hide();
            }
            var premiumFee = 0;
            if($('#isPremium1').is(':checked')){
                premiumFee = parseFloat($('#premiumFee').text());
            }
            var money = parseFloat(shipfee) - parseFloat(0) + reportFee+ parseFloat($('#cnShipFee').val())+ compressFee + woodenFee + parseFloat(removalFee) + premiumFee + parseFloat(foRemoteFee);
            $('#amount').text('￥'+ changeTwoDecimal_f(money));
            $('#cou_count').text('0');
            $('#cou_money').text('0.00');
//        }
        
    }
    $('.shiptyperadio:enabled').first().click();
    
    $('#coupon_open').click(function(){
        $('#coupon_enter').toggle();
        $('#coupon_row').show();
        return false;
    });
    $('#coupon_close').click(function(){
        $('#coupon_enter').hide();
        return false;
    });
    $('.couponno').change(function(){
        cultAmount();
    });
    
    $('#isNoPackage,#isKong').change(function(){
        if($(this).is(':checked')){
            $(this).parents('td').next().children().show();
        }else{
            $(this).parents('td').next().children().hide();
        }
    });
    
    $(':text').keypress(function(){
        $(this).next('i').hide();
    }).blur(function(){
        if($(this).val()===''){
            $(this).next('i').show();
        }
    });
    $('.sbao i').click(function(){
        $(this).prev(':text').focus();
    } );
    $('.isPremium').click(function(){
        if($('.isPremium:checked').val()==='1'){
            $('.baoxiangm').show();
            $('#premiumRow').show();
        }else{
            $('.baoxiangm').hide();
            $('#premiumRow').hide();
        }
    });
    $('#isKong').click(function(){
        if($(this).is(':checked')){
            $('#compressRow').show();
        }else{
            $('#compressRow').hide();
        }
        cultAmount();
    });
    $('#isWooden').click(function(){
        if($(this).is(':checked')){
            $('#woodenRow').show();
        }else{
            $('#woodenRow').hide();
        }
        cultAmount();
    });
    $('#isNoLogo').click(function(){
        if($(this).is(':checked')){
            $('#removalRow').show();
        }else{
            $('#removalRow').hide();
        }
        cultAmount();
    });
    $('#PremiumValue,#reprotValue').keypress(function(e){
        if((e.keyCode < 48 || e.keyCode >57) && e.keyCode != 8 && e.keyCode !=127 ){
            return false;
        }
    });
    $('#PremiumValue').change(function(){
        $('#premiumFee').text(changeTwoDecimal_f($(this).val()*0.03));
        cultAmount();
    });
});
</script>
